class CommandHistory {
  final String id;
  final String connectionId;
  final String command;
  final DateTime executedAt;
  final String output;
  final int exitCode;

  CommandHistory({
    required this.id,
    required this.connectionId,
    required this.command,
    required this.executedAt,
    required this.output,
    required this.exitCode,
  });

  Map<String, dynamic> toMap() {
    return {
      'id': id,
      'connectionId': connectionId,
      'command': command,
      'executedAt': executedAt.toIso8601String(),
      'output': output,
      'exitCode': exitCode,
    };
  }

  factory CommandHistory.fromMap(Map<String, dynamic> map) {
    return CommandHistory(
      id: map['id'],
      connectionId: map['connectionId'],
      command: map['command'],
      executedAt: DateTime.parse(map['executedAt']),
      output: map['output'],
      exitCode: map['exitCode'],
    );
  }
}